home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / langguid / chap_04 / xmpl_01.sx next >
Encoding:
Text File  |  1996-05-21  |  735 b   |  40 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Kaleida Labs, Inc.
  3. -- Field Guide to the ScriptX Language
  4. -- chapter 4, example 1
  5.  
  6. --create a module to avoid naming conflicts
  7. module Scratch13 uses ScriptX end
  8. in module Scratch13
  9.  
  10. -- case expression examples
  11.  
  12. global pet := @snake
  13. case pet of 
  14.     @cat: print "meow" 
  15.     @dog: print "woof" 
  16.     @bird: print "chirp"
  17.     @snake: print "hiss"
  18.     otherwise: print "mysterious animal noise" 
  19. end
  20.  
  21. global i:0, bool
  22. bool := case i of
  23.     0:false
  24.     1:true
  25.     otherwise: (print "out of range"; undefined)
  26. end
  27.  
  28. global a:1, b:2
  29. case of
  30.     (isComparable a b): (
  31.         case of
  32.             (a > b): print "a is greater than b" 
  33.             (a = b): print "a is equal to b" 
  34.             otherwise: print "a is less than b" 
  35.         end
  36.     )
  37.     otherwise: print "a and b are not comparable" 
  38. end
  39. -->>>
  40.